#include<iostream>
using std::endl;
using std::cout;
using std::cin;
//需要单例实现的类
class SignalItem{
public:
    static SignalItem *  getInstent(){
        if(!_si){
        atexit(destroy);
           _si = new SignalItem(98);
        }
        return _si;
    }
    void print(){
        cout<<"!!!"<<_num<<endl;
    }
    void inti(int num){
        _num = num;
    }
       static void destroy(){
            delete _si;
            _si = nullptr;
        }
private:
    SignalItem(int x)
        :_num(x){
            cout<<"SI"<<endl;
        }
        ~SignalItem(){
            cout<<"~SignalItem"<<endl;          
        }
    int _num;
    static SignalItem *_si;
};
SignalItem* SignalItem::_si = nullptr;
void test1(){
    cout<<SignalItem::getInstent()<<endl;
    SignalItem::getInstent()->inti(23);
    cout<<SignalItem::getInstent()<<endl;
    SignalItem::getInstent()->print();
    cout<<SignalItem::getInstent()<<endl;
    
}
int main(){
    test1();
    return 0;
}
